package web;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

/*****************************************************
Second servlet: generate the webpage.
*****************************************************/
public class HoroscopeToAnotherServlet extends HttpServlet {
	//1. Create the container.
		String[] Display = new String[3];
	//2. Override service method
		public void service (HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException{
			Display[0]= (String) req.getAttribute("name");
			Display[1]= (String) req.getAttribute("isNameNull");
			Display[2]= (String) req.getAttribute("future");
			
			res.setContentType("text/html");
			PrintWriter out = res.getWriter();
			
			out.println("<html><body>\n");
			if(Display[1].equals("true")){
				out.println("Please identify yourself " +
				"(by indicating your name),<br> "+ 
				"so that your horoscope can be " +
				"given!");
			}
			else {
			out.println("<p>"+Display[0]+","+ Display[2]);
			}
			out.println("</body></html>");
			out.close();		
		}
}
